/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.cognition.util.marshal;

/**
 *
 * @author richard
 */
public class ShortMarshaller {
    public static final int MARSHAL_SIZE = 2;

    public static short unmarshal(byte[] b) throws IllegalArgumentException{
        if (b == null || b.length < MARSHAL_SIZE)
            throw new IllegalArgumentException(
                    "cannot unmarshal a byte array that is null or too short.");
        return (short)(
            (int) (0xff & b[2]) << 8 |
            (int) (0xff & b[3]) << 0);

    }
}
